<template>
	<view>
		<rich-text :nodes="strings"></rich-text>
		<view>
		<button @click="handleClick(before)">上一条</button>
		<button @click="backToIndex">回到首页</button>
		<button @click="backToNews">回到列表</button>
		<button @click="handleClick(after)">下一条</button>
		</view>
	</view>
</template>

<script setup lang="ts">
	import {ref,reactive} from "vue";
	import ajax from "@/util/request";
	import {
		onLoad
	} from "@dcloudio/uni-app";
	
	const strings = ref("");
	const before = ref({});
	const after = ref({});
	
	onLoad((option) => {
		console.log("detail.option = ",option);
		// 获取页面堆栈信息
		console.log("currentPages = ",getCurrentPages());
		ajax("/content/queryRow",{t_content_pk:option.t_content_pk}).then(({data}) => {
			if (data.status > 0) {
				strings.value = data.result_data.content;
				before.value = data.before;
				after.value = data.after;
			}
		})
	});
	
	function handleClick(item) {
		uni.navigateTo({
			url:"/pages/news/detail?t_content_pk=" + item.t_content_pk,
			// success(result) {
			// 	console.log("跳转result = ",result);
			// 	result.eventChannel.emit("sibling",item);
			// }
		})
	}
	
	function backToIndex() {
		uni.reLaunch({
			url:"/pages/index/index?page=detail",
		})
	}
	
	function backToNews() {
		uni.switchTab({
			url:"/pages/news/news",
			success() {
				uni.$emit("openNews",{name: "detail"})
			}
		})
	}
</script>

<style>

</style>
